package com.fau.ss.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.time.DateFormatUtils;
import org.hibernate.annotations.GenericGenerator;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 员工业绩统计实体类
 * @author dangjh
 * @datetime 2014年10月10日 下午8:42:58
 */
@Entity
@Table(name = "medical_ss_performance")
public class MedicalSsPerformance implements Serializable, JSONAware {

	private static final long serialVersionUID = 430154152193166966L;

	private String id;
	private String platformId;		// 中心id
	private String platformName;	// 中心名称
	private String groupId;			// 组id
	private String groupName;		// 组名称
	private String userId;			// 用户id
	private String userName;		// 用户名称
	private String orderId;			// 订单id
	private BigDecimal orderMoney;	// 订单总金额
	private String hospitalId;		// 医院(企业)id
	private Date createTime = new Date();
	
	// 以下为临时字段
	private Long countOrders;
	private BigDecimal orderSumMoney;
	private String startTime;
	private String endTime;
	
	public MedicalSsPerformance(){
	}
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "platform_id", length = 32)
	public String getPlatformId() {
		return platformId;
	}

	public void setPlatformId(String platformId) {
		this.platformId = platformId;
	}

	@Column(name = "platform_name", length = 50)
	public String getPlatformName() {
		return platformName;
	}

	public void setPlatformName(String platformName) {
		this.platformName = platformName;
	}

	@Column(name = "group_id", length = 32)
	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	@Column(name = "group_name", length = 50)
	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	@Column(name = "user_id", length = 32)
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	@Column(name = "user_name", length = 50)
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name = "order_id", length = 32)
	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	@Column(name = "order_money", length = 20)
	public BigDecimal getOrderMoney() {
		return orderMoney;
	}

	public void setOrderMoney(BigDecimal orderMoney) {
		this.orderMoney = orderMoney;
	}

	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Transient	
	public Long getCountOrders() {
		return countOrders;
	}

	public void setCountOrders(Long countOrders) {
		this.countOrders = countOrders;
	}

	@Transient
	public BigDecimal getOrderSumMoney() {
		return orderSumMoney;
	}

	public void setOrderSumMoney(BigDecimal orderSumMoney) {
		this.orderSumMoney = orderSumMoney;
	}

	@Transient
	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	@Transient
	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("platformId", platformId);
		obj.put("platformName", platformName);
		obj.put("groupId", groupId);
		obj.put("groupName", groupName);
		obj.put("userId", userId);
		obj.put("userName", userName);
		obj.put("orderId", orderId);
		obj.put("orderMoney", orderMoney);
		obj.put("countOrders", countOrders);
		obj.put("orderSumMoney", orderSumMoney);
		obj.put("createTime", DateFormatUtils.format(createTime, "yyyy-MM-dd HH:mm:ss"));
		obj.put("startTime", startTime);
		return obj.toJSONString();
	}

}
